home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls001a.1 / tmp / perms / prep.xsrvr-f next >
Encoding:
Text File  |  1992-04-23  |  3.2 KB  |  144 lines

  1. :
  2. #
  3. #    @(#) prep.xsrvr 1.25 91/11/15 
  4. #
  5. # Define return values
  6. : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  7.  
  8. # Define traps for critical and non critical code.
  9. trap 'echo "\nInterrupted! Exiting ..."; cleanup $FAIL' 1 2 3 15
  10.  
  11. tmp=/tmp/xx$$
  12. LIBDIR=/usr/lib/X11
  13.  
  14. # Files and dirs to back up.
  15. BUFILES="$LIBDIR/fonts/misc/fonts.alias     \
  16.     $LIBDIR/fonts/100dpi/fonts.alias    \
  17.     $LIBDIR/fonts/75dpi/fonts.alias    \
  18.     $LIBDIR/rgb.txt "
  19.  
  20. BUDIRS="/usr/lib/grafinfo \
  21.     $LIBDIR/keymaps \
  22.     $LIBDIR/csxmaps \
  23.     $LIBDIR/xsconfig "
  24.  
  25. # Files and dirs to remove.
  26. RMFILES="/usr/lib/grafinfo/moninfo    \
  27.     $LIBDIR/.Xsight.cfg         \
  28.     /usr/bin/X11/Xsight        \
  29.     /usr/lib/vidconf/devices       \
  30.     /usr/man/cat.X/Xsco.X.z       \
  31.     /usr/man/cat.X/X.X.z           \
  32.     /usr/man/cat.X/bdftosnf.X.z       \
  33.     /usr/man/cat.X/mkfntdir.X.z       \
  34.     /usr/man/cat.X/mkfontdir.X.z       \
  35.     /usr/man/cat.X/rgb.X.z       \
  36.     /usr/man/cat.X/showrgb.X.z       \
  37.     /usr/man/cat.X/xinit.X.z       \
  38.     /usr/man/cat.X/xmodmap.X.z       \
  39.     /usr/man/cat.X/showsnf.X.z       \
  40.     /usr/man/cat.X/startx.X.z       \
  41.     /usr/man/cat.X/clnscrn.X.z     \
  42.     /usr/man/cat.X/xswkey.X.z       \
  43.     /usr/man/cat.X/xsconfig.X.z       \
  44.     /usr/man/cat.X/xset.X.z       \
  45.     /usr/man/cat.X/xhost.X.z       \
  46.     /usr/man/cat.X/xauth.X.z"
  47.  
  48. # Functions -- 
  49. # cleanup() -- 
  50. # Remove temp files and exit with the status passed as argument
  51. # Usage: cleanup status
  52. # References: $tmp indicates prefix of files to remove
  53. # Notes: cleanup exits with whatever value it is passed.
  54. #
  55. cleanup() 
  56. {
  57.     trap '' 1 2 3 15
  58.     [ "$tmp" ] && rm -f $tmp*
  59.     exit $1
  60. }
  61.  
  62. #
  63. # create a heirarchy of directories (mkdir that makes everything)
  64. #
  65. mkdirhier()
  66. {
  67. for f in $*; do
  68.     parts=`echo $f | sed 's,\(.\)/\(.\),\1 \2,g' | sed 's,/$,,'`;
  69.     path="";
  70.     for p in $parts; do
  71.         if [ x"$path" = x ]; then
  72.         dir=$p;
  73.     else
  74.             dir=$path/$p;
  75.     fi;
  76.     if [ ! -d $dir ]; then
  77.         #echo mkdir $dir;
  78.         mkdir $dir;
  79.         chmod a+rx $dir;
  80.     fi;
  81.     path=$dir;
  82.      done;
  83. done
  84. dir=""
  85. }
  86.  
  87. # main()
  88. #
  89. # verify that the system is in single user mode
  90. # Note: cant run grep in a pipe, as it'll (the string 'getty') 
  91. # then show up on the ps output, so do it to a tmp file. 
  92. ps -ealf > $tmp
  93. grep getty $tmp >/dev/null 2>&1 
  94. [ $? -eq 0 ] && { 
  95.     echo "
  96. Error: This product must be installed in single user mode,
  97. exit from custom and type 'init 1'. 
  98. When the system is down to single user mode, 
  99. you may proceed with the custom installation of this product.
  100. "
  101.     cleanup $FAIL      
  102. }
  103.  
  104. # remove some files that we don't want around.
  105. for f in $RMFILES ; do 
  106.     [ -f $f -o -d $f ] && rm -rf $f;  
  107. done
  108.  
  109. # If the CONFIG_SAVE var is not set, set it to /usr/lib/custom/save
  110. # so that we can save some files for the user.
  111. # In the InPlace Upgrade environment, it will be set to a dir for us to 
  112. # copy the old user config files into.
  113. [ -z "$CONFIG_SAVE" ] && {
  114.     CONFIG_SAVE=/usr/lib/custom/save
  115. }
  116.  
  117. # Set up the directory to copy saved ODT-View files in to.
  118. DEST=$CONFIG_SAVE/xsight
  119. COPY="copy -r"
  120.  
  121. # do the saving of dirs
  122. for d in $BUDIRS ; do
  123.     [ -d $d ] && {
  124.         mkdirhier $DEST$d
  125.         $COPY $d $DEST$d
  126.         # remove the original
  127.         rm -rf $d
  128.     }
  129. done
  130.  
  131. # Saving of files for InPlace Upgrade
  132. for file in $BUFILES
  133. do
  134.     [ -f $file ] && {
  135.         mkdirhier  $DEST`dirname $file`
  136.         $COPY $file $DEST$file
  137.         # remove the original
  138.         rm -f $file
  139.     }
  140. done
  141.  
  142. cleanup $OK
  143.